<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box {
            height: 200px;
            width: 200px;
            background-color: red;
            position: absolute;
            left: 0;
            top: 0;
        }
    </style>
    <script>
        window.onload = function(){
        function getStyle (ele, attr) {
            if (ele.currentStyle) {
            return ele.currentStyle[attr]
            } else {
            return getComputedStyle(ele, false)[attr]
            }
    }
        function move1 (ele,attr,end,fn) {
            end = parseInt(end);
            var start = parseInt(getStyle(ele,attr))
            clearInterval(ele.timer)
            ele.timer = setInterval(function(){
                var distance = end -start;
                var speed = distance > 0 ? Math.ceil(distance / 10) : Math.floor(distance / 10)
                start += speed;
                ele.style[attr] = start + 'px';
                if(start === end){
                    clearInterval(ele.timer)
                    fn && fn();
                }
            })
        }
        document.querySelector('#box').onclick = function () {
            move1(this, 'height', u00, () => {
                move1(this, 'width', 100)
            })
        }
    }
    </script>
</head>
<body>
    <div id="box"></div>
</body>
</html>